<template>
	<view>
		<view class="uni-form-item uni-column" v-if="!FormData">
		  <view class="title">没有订单信息</view>
		</view>
		<view class="box" v-for="(item, index) in FormData" :key="index">
			<view>订单号: {{item.order_no}}</view>
			<view class="name">客户名称: {{item.user_name}}</view>
			<view class="name">缴费项目名称: {{item.item_name}}</view>
			<view>支付订单号: {{item.pay_no}}</view>
			<view class="shuangb"><text>订单类型: {{item.order_type1}}</text><text>订单状态: {{item.order_status1}}</text></view>
			<view class="shuangb"><text>发票状态: {{item.invoice_status1}}</text><text>支付金额: {{item.pay_amount}}</text></view>
			<view>支付时间: {{item.pay_time}}</view>
			<view class="cent"><text class="bdfw" @click="pay(item.order_no)">去支付</text></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				FormData: [],
			}
		},
		mounted() {
			let params = {
				page: 1,
				limit: 10,
			};
			this.init(params);
		},
		methods: {
			init(params) {
				params.payUserId = uni.getStorageSync('user').roleId
				params.ty = 1
				this.$api.getPayOrderPage(params).then((res) => {
					if(res.rows.length == 0) {
						this.FormData = ''
						return
					}
					res.rows.map(item => {
						if (item.order_type == 0) {
							item.order_type1 = '其他缴费'
						}
						if (item.order_status == 0) {
							item.order_status1 = '未支付'
						} else if (item.order_status == 1) {
							item.order_status1 = '已支付'
						}
						if (item.invoice_status == 0) {
							item.invoice_status1 = '未打印'
						} else if (item.invoice_status == 1) {
							item.invoice_status1 = '已打印'
						}
					})
					this.FormData = res.rows
					console.log(this.FormData)
				}).catch((err) => {
					console.log('request fail', err);
				})
			},
			pay(orderNo) {
				let params = {
					orderNo
				}
				this.$api.pay(params).then((res) => {
					if (res.success) {
						window.location.href = res.rows
					}
				}).catch((err) => {
					console.log('request fail', err);
				})
			}
		}
	}
</script>

<style scoped>
	.box {
		background: #F8F8FF;
		margin: 10px;
		border-radius: 10px;
		padding: 10px;
		line-height: 24px;
	}
	.name {
		font-weight: bold;
		font-size: 16px;
	}
	.shuangb {
		display: flex;
		justify-content: space-between;
	}
	.cent {
		display: flex;
		justify-content: center;
	}
	.bdfw {
		background: #007AFF;
		display: block;
		width: 100px;
		text-align: center;
		border-radius: 10px;
		color: #fff;
	}
</style>
